#!/bin/sh
if [ -z "$1" ]
  then
    echo 'usage: ./test.sh "<word_to_translate>"'
    exit
fi

echo $1 \
| lt-proc en-ru.automorf.bin \
| gawk 'BEGIN{RS="$"; FS="/";}{nf=split($1,COMPONENTS,"^"); for(i = 1; i<nf; i++) printf COMPONENTS[i]; if($2 != "") printf("^%s$",$2);}' \
| apertium-transfer apertium-en-ru.en-ru.t1x en-ru.t1x.bin en-ru.autobil.bin \
| lt-proc -g en-ru.autogen.bin

echo


